package com.zhu.day.model;

import org.springframework.util.CollectionUtils;

import java.util.*;

public class LuckyUtil {
    public static final Integer numbers = 4;

    public static Set<String> createRandoms(Set<String> set, int n) {
        if (CollectionUtils.isEmpty(set)){
            return new HashSet<>();
        }
        List<String> list = Arrays.asList(set.toArray(new String[0]));
        Map<Integer, String> map = new HashMap();
        Set<String> news = new HashSet<>();

        if (list.size() <= n) {
            return new HashSet<>(list);
        } else {
            while (map.size() < n) {
                int random = (int) (Math.random() * list.size());
                if (!map.containsKey(random)) {
                    map.put(random, "");

                    news.add(list.get(random));
                }
            }
            return news;
        }
    }



    public static void main(String[] args) {
//        Set<String> list = new HashSet<>();
//        for (int i = 0; i < 100; i++) {
//            list.add(String.valueOf(i));
//        }
//        System.out.println(LuckyUtil.createRandoms(list,LuckyUtil.numbers));

        Set<String> basicList = new HashSet<>();
        Set<String> basicListRem = new HashSet<>();
        basicList.removeAll(basicListRem);
    }
}
